package vip.xiaozhao.intern.baseUtil.service.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import vip.xiaozhao.intern.baseUtil.intf.service.VVService;

/**
 * 大V相关定时任务
 */
@Component
@EnableScheduling
@Slf4j
public class VVScheduleTask {

    @Autowired
    private VVService vvService;
    
    /**
     * 每天半夜2点更新同公司同职位大V缓存
     * 每天半夜3点更新同职位大V缓存
     */
    @Scheduled(cron = "0 0 2,3 * * ?")
    public void updateVVCache() {
        log.info("开始执行大V缓存更新定时任务");
        boolean result = vvService.updateVVCache();
        log.info("大V缓存更新定时任务执行完成，结果：{}", result ? "成功" : "失败");
    }
    
    /**
     * 每天半夜4点更新大V周回答率
     */
    @Scheduled(cron = "0 0 4 * * ?")
    public void updateWeekAnswerStats() {
        log.info("开始执行大V周回答率更新定时任务");
        int updateCount = vvService.updateWeekAnswerStats();
        log.info("大V周回答率更新定时任务执行完成，更新数量：{}", updateCount);
    }
} 